<?php

/**
 * This is the model class for table "mtsys_basetype".
 *
 * The followings are the available columns in table 'mtsys_basetype':
 * @property integer $RECORD_ID
 * @property string $BASE_TYPE
 * @property integer $YELTHRMAXRED_N
 * @property integer $YELTHRMAXYEL_N
 * @property integer $GRETHRMAXYEL_N
 * @property integer $GRETHRMAXRED_N
 * @property string $REMARK
 * @property string $CREATE_DATE
 */
class MtsysBasetype extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return MtsysBasetype the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'mtsys_basetype';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('BASE_TYPE, YELTHRMAXRED_N, YELTHRMAXYEL_N, GRETHRMAXYEL_N, GRETHRMAXRED_N', 'required'),
			array('BASE_TYPE', 'unique', 'message' => '已存在该站点类型，不允许重复创建'),
			array('YELTHRMAXRED_N, YELTHRMAXYEL_N, GRETHRMAXYEL_N, GRETHRMAXRED_N', 'numerical', 'integerOnly'=>true),
			array('BASE_TYPE, REMARK', 'length', 'max'=>255),
			array('CREATE_DATE', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('RECORD_ID, BASE_TYPE, YELTHRMAXRED_N, YELTHRMAXYEL_N, GRETHRMAXYEL_N, GRETHRMAXRED_N, REMARK, CREATE_DATE', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'RECORD_ID' => '流水',
			'BASE_TYPE' => '电池组警告条件',
			'YELTHRMAXRED_N' => '黄色警告门限值（红色电池最大数）',
			'YELTHRMAXYEL_N' => '黄色警告门限值（黄色电池最大数）',
			'GRETHRMAXYEL_N' => '绿色正常门限值（黄色电池最大数）',
			'GRETHRMAXRED_N' => '绿色正常门限值（红色电池最大数）',
			'REMARK' => '备注',
			'CREATE_DATE' => '创建日期',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('RECORD_ID',$this->RECORD_ID);
		$criteria->compare('BASE_TYPE',$this->BASE_TYPE,true);
		$criteria->compare('YELTHRMAXRED_N',$this->YELTHRMAXRED_N);
		$criteria->compare('YELTHRMAXYEL_N',$this->YELTHRMAXYEL_N);
		$criteria->compare('GRETHRMAXYEL_N',$this->GRETHRMAXYEL_N);
		$criteria->compare('GRETHRMAXRED_N',$this->GRETHRMAXRED_N);
		$criteria->compare('REMARK',$this->REMARK,true);
		$criteria->compare('CREATE_DATE',$this->CREATE_DATE,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}